<div class="page_header">
    <div class="page_center">
        <img src="{{ request.session.headimgurl }}">
        <p>{{ request.session.nickname }}</p>
    </div>
</div>
<div class="nav_header">
    <div class="weui-flex">
     {% if request.session.role == 2 or request.session.role == 1 %}
      <a href="{% url 'my-order-list' %}" class="weui-flex__item placeholder"><i class="icon iconfont icon-orderlisto" ></i>我的订单<span id="order_nums" class="weui-badge" style="margin-top: -15px;">0</span></a>
      <a class="weui-flex__item placeholder" href="javascript:;"><i class="icon iconfont icon-jiaoyi1" ></i>余额<span id="mybalance">0.00</span>元</a>
     {% endif %}
    </div>
</div>
<script>
    $(function(){

        getMyDeposit();
        getMyOrderCount();
    });

    function getMyDeposit(){
        $.ajax({
              type: 'GET',
              url: '{% url "member-deposit" %}',
              dataType: 'json',
              timeout: 5000,
              success: function(data){
{#                  alert(JSON.stringify(data));#}
                  $("#mybalance").text(data.balance.toFixed(2) || 0.00);
              },
              error: function(error){}
            });
    }

    function getMyOrderCount(){
        $.ajax({
          type: 'GET',
          url: '{% url "order-cart-count" %}',
          data:{ order:1, _rand:Math.random() },
          dataType: 'json',
          timeout: 5000,
          success: function(data){
              $('#order_nums').text(data.order_nums);

          },
          error: function(xhr, type,error){}
        });
    }

    function appendItem(data){
        $.each(data,function(index,item){
{#            alert(JSON.stringify(item));#}
            newItem =  '<div class="weui-cell">';
            newItem += '<div class="weui-cell__bd">';
            newItem += '<span class="weui-badge" style="margin-left: 5px;margin-right: 5px;">'+ item.scores +'</span>';
            newItem += '<span style="vertical-align: middle">积分</span>';
            newItem += '</div>';
            newItem += '<div class="weui-cell__ft">' + item.create_at +'</div>';
            newItem += '</div>';
            $("#scoreslist").append( newItem );
        });
    }

 </script>
